package crazyFace.system.app;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Rect;
 
public class Button {
	private Bitmap bmp;
	private int x = 0;
	private int y = 0;
	private int width;
	private int height;
	protected int instruction = 1;
 
	public Button(Bitmap bmp, int x, int y) {
		this.width = bmp.getWidth();
		this.height = bmp.getHeight();
		this.bmp = bmp;
		this.x = x - (bmp.getWidth() / 2);
		this.y = y - (bmp.getHeight() / 2);
	}
       
	public Button(Bitmap bmp, int x, int y, int instruction) {
		this.width = bmp.getWidth();
		this.height = bmp.getHeight();
		this.bmp = bmp;
		this.x = x - (bmp.getWidth() / 2);
		this.y = y - (bmp.getHeight() / 2);
		setAction(instruction);
	}
	
	public Button(Bitmap bmp, int x, int y, int width, int height, int instruction) {
		this.width = width;
		this.height = height;
		this.bmp = bmp;
		this.x = x - (bmp.getWidth() / 2);
		this.y = y - (bmp.getHeight() / 2);
		setAction(instruction);
	}
	
	
 
	public void onDraw(Canvas canvas) {
		
		Rect src = new Rect(0, 0, width, height);
		Rect dst = new Rect(x, y, x + width, y + height);
		canvas.drawBitmap(bmp, src, dst, null);
	}
 
	public boolean isCollition(float x2, float y2) {
		return x2 > x && x2 < x + width && y2 > y && y2 < y + height;
	}
       
	public void setAction(int action){
		this.instruction = action;
	}
       
	public int getAction(){
		return instruction;
	}
}